from comicinfo.models import ComicInfo, ComicKind, ComicIndex, ComicDetail
from rest_framework import serializers


class ComicDetailSerializer(serializers.ModelSerializer):

    class Meta:
        model = ComicDetail
        fields = '__all__'


class ComicIndexSerializer(serializers.ModelSerializer):
    comic_detail = ComicDetailSerializer(many=True, required=False, read_only=True)

    class Meta:
        model = ComicIndex
        # fields = ('id', 'catalog_title', 'catalog_desc', 'comic_detail', 'catalog_url')
        fields = '__all__'


class ComicKindSerializer(serializers.ModelSerializer):

    class Meta:
        model = ComicKind
        fields = '__all__'


class ComicInfoSerializer(serializers.ModelSerializer):
    kind = ComicKindSerializer(many=True)
    comic_index = ComicIndexSerializer(many=True, required=False, read_only=True)

    class Meta:
        model = ComicInfo
        # fields = ('id', 'book_name', 'description', 'popularity', 'book_url',
        #           'book_area', 'book_type', 'book_img', 'content_url', 'kind', 'comic_index')
        fields = '__all__'


